<section class="field pms-field">
  {{#if field.metadata.value.length}}
    <section class="actions header">
      {{fields/da-field-label label=label field=field}}
      {{d-button
        icon="plus"
        action=(action "insertPM")
        class="btn-primary insert-pm"
      }}
    </section>
  {{/if}}

  {{#each field.metadata.value as |pm|}}
    <div class="pm-field">
      <div class="control-group">
        {{fields/da-field-label label=(i18n "discourse_automation.fields.pms.title.label") field=field}}
        <div class="controls">
          <div class="field-wrapper">
            {{input
              id=(concat field.target field.name "title")
              value=pm.title
              class="pm-input pm-title"
              input=(action (mut pm.title) value="target.value")
              disabled=field.isDisabled
            }}

            {{#if displayPlaceholders}}
              {{placeholders-list
                currentValue=pm.title
                placeholders=placeholders
              }}
            {{/if}}
          </div>
        </div>
      </div>

      <div class="control-group">
        {{fields/da-field-label label=(i18n "discourse_automation.fields.pms.raw.label") field=field}}
        <div class="controls">
          <div class="field-wrapper">
            {{d-editor value=pm.raw}}

            {{#if displayPlaceholders}}
              {{placeholders-list
                currentValue=pm.raw
                placeholders=placeholders
              }}
            {{/if}}
          </div>
        </div>
      </div>

      <div class="control-group">
        <label class="control-label">
          {{i18n "discourse_automation.fields.pms.delay.label"}}
        </label>

        <div class="controls">
          {{input
            value=pm.delay
            class="input-large pm-input"
            input=(action (mut pm.delay) value="target.value")
            disabled=field.isDisabled
          }}
        </div>
      </div>

      <div class="control-group">
        <label class="control-label">
          {{i18n "discourse_automation.fields.pms.encrypt.label"}}
        </label>

        <div class="controls">
          {{input
            type="checkbox"
            checked=pm.encrypt
            click=(action (mut pm.encrypt) value="target.checked")
            disabled=field.isDisabled
          }}
        </div>
      </div>
      <section class="actions">
        {{d-button
          icon="trash-alt"
          action=(action "removePM" pm)
          class="btn-danger"
          disabled=field.isDisabled
        }}
      </section>
    </div>
  {{else}}
    <div class="no-pm">
      <p>{{i18n "discourse_automation.fields.pms.no_pm_created"}}</p>
      {{d-button
        icon="plus"
        label="discourse_automation.fields.pms.add_pm"
        action=(action "insertPM")
        class="btn-primary insert-pm"
        disabled=field.isDisabled
      }}
    </div>
  {{/each}}
</section>
